package com.groupbuying.redpacket.controller;


import com.groupbuying.redpacket.service.CustomerService;
import com.groupbuying.redpacket.service.RuleService;
import com.groupbuying.redpacket.utils.apiresult.ApiResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @Author: mayunfei
 * @Date: Create in 12:02 2019/11/21
 * @tar:
 */
@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private CustomerService customerService;

    /**
     * @api {post} /login/getLogin 登录
     * @apiExample
     * author mayunfei
     * tar 用于: 微信小程序
     * date 2019/11/22
     * @apiGroup service-redpacket
     * @apiVersion 1.0.0
     * @apiHeader {String} Authorization 用户授权token
     * @apiParam {String} mobile 手机
     * @apiParam {String} password 密码
     * @apiSuccess {ApiResult} success:登录成功; failure:请求
     * @apiSuccess {ApiResult}  failure:请求
     * @apiSuccess {ApiResult}  access_token失败
     */
    @PostMapping("/getLogin")
    public ApiResult Login(@RequestParam Map<String, Object> params) {
      return customerService.login(params);
    }

    /**
     * @api {post} /login/verificationCodeLogin 手机号验证码登录
     * @apiExample
     * author mayunfei
     * tar 用于:微信小程序
     * date 2019/11/22
     * @apiGroup service-redpacket
     * @apiVersion 1.0.0
     * @apiHeader {String} Authorization 用户授权token
     * @apiParam {String} mobile 手机
     * @apiParam {String} code 验证码
     * @apiSuccess {ApiResult} success:登录成功; failure:请求
     * @apiSuccess {ApiResult}  failure:请求
     * @apiSuccess {ApiResult}  access_token失败
     */
    @PostMapping("/verificationCodeLogin")
    public ApiResult verificationCodeLogin(@RequestParam Map<String,Object> map)throws Exception{
        return customerService.verificationCodeLogin(map);
    }
    /**
     * @api {post} /login/identifyingCode 验证码
     * @apiExample
     * author mayunfei
     * tar 用于:微信小程序
     * date 2019/11/22
     * @apiGroup service-redpacket
     * @apiVersion 1.0.0
     * @apiHeader {String} Authorization 用户授权token
     * @apiParam {String} mobile 手机
     * @apiSuccess {ApiResult} success:登录成功; failure:请求
     * @apiSuccess {ApiResult}  failure:请求
     * @apiSuccess {ApiResult}  access_token失败
     */
    @PostMapping("/identifyingCode")
    public ApiResult identifyingCode(@RequestParam Map<String,Object> map)throws Exception{
        return customerService.identifyingCode(map);
    }



}
